﻿using System;
using ASPItalia.ModelVirtualCasting.EntityFramework.Wrappers;

namespace ASPItalia.ModelVirtualCasting.EntityFramework
{
	public class ThreadContextContainer: IContextContainer
	{
		[ThreadStatic]
		private static ContextWrapper _currentContext;

		public ContextWrapper Current
		{
			get { return _currentContext ?? ( _currentContext = new ContextWrapper(new ModelVirtualCastingEntities(Configuration.ConnectionString))); }
		}

		public void Clear()
		{
			_currentContext = new ContextWrapper(new ModelVirtualCastingEntities(Configuration.ConnectionString));
		}
	}
}
